package uva.tests;

import static org.junit.Assert.*;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

import org.junit.Test;

import rice.environment.Environment;
import rice.pastry.NodeIdFactory;
import rice.pastry.PastryNode;
import rice.pastry.routing.RoutingTable;
import uva.MaliciousNodeFactory;
import uva.MaliciousRandomIdFactory;
import uva.RoutingTableManager;

public class RoutingManagerTests {

	@Test
	public void testReconciledTable() throws IOException {
//		int myport = 9001;
//		int bootport = 9001;
//
//		String ipAddress = "192.168.1.103";
//
//		// Loads pastry settings
//		Environment env = new Environment();
//
//		// disable the UPnP setting (in case you are testing this on a NATted
//		// LAN)
//		env.getParameters().setString("nat_search_policy", "never");
//
//		// build the bootaddress from the command line args
//		InetAddress bootaddr = InetAddress.getByName(ipAddress);
//
//		InetSocketAddress bootaddress = new InetSocketAddress(bootaddr, bootport);
//		
//		NodeIdFactory nidFactory = new MaliciousRandomIdFactory(env);
//		MaliciousNodeFactory factory = new MaliciousNodeFactory(nidFactory, myport, env);
//		
//		PastryNode node = factory.newNode(false);
//		RoutingTable table = new RoutingTable(node.getLocalHandle(), 1, (byte)4, node, true);
//		RoutingTableManager manager = new RoutingTableManager(table);
//		
//		PastryNode node1 = factory.newNode(false);
//		System.out.println("node1 is: " + node1.getId().toStringFull());
//		manager.Put(0, node1.getLocalHandle());
//		System.out.println("0: "+manager.getTable(0).printSelf());
//		manager.Put(1, node1.getLocalHandle());
//		System.out.println("1: " + manager.getTable(1).printSelf());
//		System.out.println("2: " + manager.getTable(2).printSelf());
//		System.out.println("reconciled table: " + manager.getMainTable().printSelf());
		
	}

}
